import Vue from 'vue'
import Vuex from 'vuex'
import userStore from './modules/user'

Vue.use(Vuex)

const store = new Vuex.Store({
  state: {
    count1: 10,
    count2: 2,
    orderTime: '12:00'
    // ...
  },
  mutations: {
    increment (state, n) {
      state.count1+= n
    }
  },
  actions: {
    incrementAsync (state, n) {
      console.log(222)
      setTimeout(() => {
        state.commit('increment', n)
      }, 1000)
    }
  },
  getters: {
    countResult: state => {
      return state.count1 + state.count2
    }
  },
  modules: {
    userStore
  }
})
export default store